#ifndef	_PING_H_
#define	_PING_H_

#include "common.h"
#include "w5500_conf.h"
#include "w5500.h"
#include "socket.h"
#include "utility.h"

#define BUF_LEN 		32
#define PING_REQUEST 	8
#define PING_REPLY 		0
#define CODE_ZERO 		0

#define SOCKET_ERROR 	1
#define TIMEOUT_ERROR 	2
#define SUCCESS 		3
#define REPLY_ERROR 	4

#define PING_NUM		1
typedef struct pingmsg
{
  uint8_t  Type; 		// 0 - Ping Reply, 8 - Ping Request
  uint8_t  Code;		// Always 0
  uint16_t  CheckSum;	// Check sum
  uint16_t  ID;	        // Identification
  uint16_t  SeqNum; 	// Sequence Number
  int8_t  Data[BUF_LEN];// Ping Data  : 1452 = IP RAW MTU - sizeof(Type+Code+CheckSum+ID+SeqNum)
} PINGMSGR;


void ping_auto(uint8_t s, uint8_t *addr);
uint8_t ping_request(uint8_t s, uint8_t *addr);
uint8_t ping_reply(uint8_t s,  uint8_t *addr, uint16_t rlen);
void do_ping(void);
#endif
